<!doctype html>
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
	<link rel="stylesheet" href="{$url_css}bootstrap.min.css" type="text/css">
	<script type="text/javascript" src="{$url_js}jquery-1.12.0.min.js"></script>
	<script type="text/javascript" src="{$url_js}bootstrap.min.js"></script>
	<script type="text/javascript" src="{$url_js}calendar/WdatePicker.js"></script>
	<title>系统公告管理</title>
</head>
<body>
<br/>
<div style="width:96%" class="container">

	<ul class="nav nav-tabs">
		<li class="active"><a href="#public" data-toggle="tab">公用消息发送</a></li>
		<li><a href="#personal" data-toggle="tab">个人消息发送</a></li>
	</ul>
	<br/>

	<div class="tab-content">
		<div id="public" class="tab-pane active">
			<form method="post" id="public-form">
				<table class="table table-striped table-bordered" align="center">
					<tr>
						<th colspan="2">消息管理</th>
					</tr>
					<tr>
						<td width="15%">消息分类</td>
						<td>
							<select name="tid" class="form-control" style="width: 200px">
								<option value="0">==选择消息分类==</option>
								<option value="1">商家有礼消息</option>
								<option value="2">低价团消息</option>
							</select>
						</td>
					</tr>
					<tr>
						<td width="15%">消息类型</td>
						<td>
							<select name="type" class="form-control" style="width: 200px">
								<option value="0">==选择消息类型==</option>
								{foreach $types as $k => $v}
									<option value="{$k}">{$v}</option>
								{/foreach}
							</select>
						</td>
					</tr>
					<tr class="input_data">
						<td>数据</td>
						<td>
							<input class="form-control" type="text" class="span6" name="data" style="width: 80%"/>
							<br/>
							[活动结果即将公布通知 -> 活动id]<br/>
							[结果公示通知 -> 活动id]<br/>
							[活动获奖通知 -> 活动id]<br/>
							[邀请人消息 -> 用户id]<br/>
							[系统消息 -> 消息id]<br/>
							[赠送金果 -> 消息内容]<br/>
							[电子券获奖通知 -> 活动id]<br/>
						</td>
					</tr>
					<tr>
						<td>&nbsp;</td>
						<td>
							<input type="button" class="btn btn-danger" id="public-submit" value="提交"/>
							请谨慎填写，一但提交系统不可取消！
						</td>
					</tr>
				</table>
			</form>
		</div>

		<div class="tab-pane fade" id="personal">
			<form method="post" id="personal-form">
				<table class="table table-striped table-bordered" align="center">
					<tr>
						<th colspan="2">消息管理</th>
					</tr>
					<tr>
						<td>
							用户ID<br/>
							多个用英文逗号(',')隔开
						</td>
						<td>
							<input class="form-control" type="text" class="input-xlarge" name="uid" style="width: 80%"
							       placeholder="用户ID"/>
						</td>
					</tr>
					<tr>
						<td width="15%">消息分类</td>
						<td>
							<select name="tid" class="form-control" style="width: 200px">
								<option value="0">==选择消息分类==</option>
								<option value="1">商家有礼消息</option>
								<option value="2">低价团消息</option>
							</select>
						</td>
					</tr>
					<tr>
						<td width="15%">消息类型</td>
						<td>
							<select name="type" class="form-control" style="width: 200px">
								<option value="0">==选择消息类型==</option>
								{foreach $types as $k => $v}
									<option value="{$k}">{$v}</option>
								{/foreach}
							</select>
						</td>
					</tr>
					<tr class="input_data">
						<td>数据</td>
						<td>
							<input class="form-control" type="text" class="span6" name="data" style="width: 80%"/>
							<br/>
							[活动结果即将公布通知 -> 活动id]<br/>
							[结果公示通知 -> 活动id]<br/>
							[活动获奖通知 -> 活动id]<br/>
							[邀请人消息 -> 用户id]<br/>
							[系统消息 -> 消息id]<br/>
							[赠送金果 -> 消息内容]<br/>
							[电子券获奖通知 -> 活动id]<br/>
						</td>
					</tr>
					<tr>
						<td>&nbsp;</td>
						<td>
							<input type="button" class="btn btn-danger" id="personal-submit" value="提交"/>
							请谨慎填写，一但系统不可取消！
						</td>
					</tr>
				</table>
			</form>
		</div>
	</div>
</div>

<script type="text/javascript">
	{literal}
    function show_down(main) {
//        var cur = main.find("select[name=type]");
//        cur.change(function () {
//            var input_data = main.find('.input_data');
//            if (cur.val() == 1) {
//                input_data.find('input').val('');
//                input_data.hide();
//            } else {
//                input_data.show();
//            }
//        });
    }

    show_down($("#public-form"));
    show_down($("#personal-form"));
    var sending = false;

    $("#public-submit").click(function () {
        top.swal({
            title: '发送确认',
            text: '请谨慎填写，一旦提交不可撤销!',
            type: "warning",
            showCancelButton: true,
            cancelButtonText: '取消',
            confirmButtonColor: "#DD6B55",
            confirmButtonText: "确定",
            closeOnConfirm: false
        }, function () {
            top.swal({
                title: "正在发送！",
                text: "请不要进行操作",
                showConfirmButton: false
            });
            $.ajax({
                url: 'notice.php?do=SendAll',
                type: 'post',
                data: $('#public-form').serialize(),
                dataType: 'json',
                success: function (re) {
                    if (re.status == false) {
                        top.swal(re.msg, re.type);
                    } else {
                        if (re.type == 'success') {
                            $("#public-form").get(0).reset();
                            top.swal('发送成功', 'success');
                        } else {
                            top.swal('发送失败,请稍后再试!', 'error');
                        }
                    }
                }
            });
        });
    });

    $("#personal-submit").click(function () {
        top.swal({
            title: '发送确认',
            text: '请谨慎填写，一旦提交不可撤销!',
            type: "warning",
            showCancelButton: true,
            cancelButtonText: '取消',
            confirmButtonColor: "#DD6B55",
            confirmButtonText: "确定",
            closeOnConfirm: false
        }, function () {
            top.swal({
                title: "正在发送！",
                text: "请不要进行操作",
                showConfirmButton: false
            });
            $.ajax({
                url: 'notice.php?do=SendPerson',
                type: 'post',
                data: $('#personal-form').serialize(),
                dataType: 'json',
                success: function (re) {
                    if (re.status == false) {
                        top.swal(re.msg, re.type);
                    } else {
                        if (re.type == 'success') {
                            $("#personal-form").get(0).reset();
                            top.swal('发送成功', 'success');
                        } else {
                            top.swal('发送失败,请稍后再试!', 'error');
                        }
                    }
                }
            });
        });
    });
	{/literal}
</script>
</body>
</html>